Rule: Fix temporary rule filename composition issue #4468
Merged
+16
−10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Signed-off-by: Matej Gera [email protected]
Changes
Provides a fix for current issue with rule filenames, which are being written into a
.tmp-rules
directory for further processing. As was discovered in the linked issue, the current implementation could lead to temporary rule filenames being composed in a way, where trimming of the filename leads to unexpected result, i.e. theTrimLeft
function can in some cases trim the filename in a way which results in duplication of temporary rule filenames. This in turn manifests itself as some rules being 'ignored' by the rule component.Since trimming the filename does not seem to have the desired effect, the fix proposed here is to simply leave the full filename as is, which practically leads to same result but without possible name duplication issue.
Fixes #4232
Verification
Related tests have been updated to assess the fix is working; also tested manually with local run of
thanos rule